package com.yonyou.base.user.impl;

import com.yonyou.base.common.utils.EncodePasswordService;
import com.yonyou.base.user.dao.IUserDao;
import com.yonyou.base.user.model.UserVO;
import com.yonyou.base.user.service.IUserService;
import com.yonyou.hrcloud.adder.model.query.Condition;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

@Service
@Transactional(readOnly = true)
public class UserServiceImpl implements IUserService {

    @Resource
    private IUserDao userDao;

    @Resource
    private EncodePasswordService passwordService = null;


    @Transactional
    @Override
    public void insertUser(UserVO userVO) {
        userDao.insert(userVO);
    }


    @Override
    public List<UserVO> queryUserListByCondition(Condition condition, Sort sort) {
        return userDao.queryUserListByCondition(condition, sort);
    }


    @Transactional
    @Override
    public void resetUserPassword(String id, String username, String password) {
        // 密码加密
        userDao.resetUserPassword(passwordService.encodePassword(username, password), id);
    }

}
